package com.rest.demo.functional;

import java.util.function.Function;

/**
 * @author Administrator
 * @decription
 * @Date 2018-01-26 15:56
 */
public class ConverterDemo {
    public static void main(String[] args) {
        Converter<String,Integer> converter = Integer::valueOf;
        Integer result = converter.convert("123");
        System.out.println(result);

        Start start = new Start();
        Converter<String,String> indexString = start::startWith;
        System.out.println(indexString.convert("JAVA"));

        Function<String, Integer> toInteger = Integer::valueOf;
        Function<String, String> backToString = toInteger.andThen(String::valueOf);
        System.out.println(backToString.apply("123"));
    }
}

class Start {
    String startWith(String from) {
        return String.valueOf(from.charAt(0));
    }
}
